﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Collections;
using DotNet.Highcharts;
using DotNet.Highcharts.Options;
using DotNet.Highcharts.Enums;
using DotNet.Highcharts.Helpers;
namespace FTchina.ESS
{
    /// <summary>
    ///ESSHighchart 的摘要说明
    /// </summary>
    public class ESSHighchart
    {
        public static string[] Categories = new[] { "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月" };
        public static string[] MonthID = new[] { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" };



        int ChartWidth = 800;//图形宽度
        int ChartHeight = 500;//图形高度
        PWMIS.DataProvider.Data.AdoHelper AdoHelper = PWMIS.DataProvider.Adapter.MyDB.GetDBHelperByConnectionName("DYDB");//数据库助手


        /// <summary>
        /// 看是否是东营市老总，是的话看所有的分公司
        /// </summary>
        public Boolean IsDYAdmin { get; set; }

        public ESSHighchart()
        {
            //
            //TODO: 在此处添加构造函数逻辑
            //
        }



        /// <summary>
        /// 将分公司名称绑定到下拉列表
        /// </summary>
        /// <param name="ddl"></param>
        public void FillDDLwithDpt(FineUI.DropDownList ddl)
        {
            string sql = "SELECT DISTINCT t.BIG_DEPT_NAME FROM ess_chart_yw_ywsrjyhs  t where t.BIG_DEPT_NAME<>'公务测试'";
            ddl.DataSource = AdoHelper.ExecuteDataSet(sql);
            ddl.DataTextField = "BIG_DEPT_NAME";
            ddl.DataValueField = "BIG_DEPT_NAME";
            ddl.DataBind();
        }


        /// <summary>
        /// ESS移网数据，
        /// X=用户类型，Y=合计数
        /// </summary>
        /// <returns></returns>
        public string ChartEssDeviceCountByCitycode()
        {
            string[] categories = new[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
            object[] tokioData = new object[] { 7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6 };
            object[] londonData = new object[] { 3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8 };

            Highcharts chart = new Highcharts("chart")
                .InitChart(new Chart { DefaultSeriesType = ChartTypes.Line })
                .SetTitle(new Title { Text = "Monthly Average Temperature" })
                .SetSubtitle(new Subtitle { Text = "Source: WorldClimate.com" })
                .SetXAxis(new XAxis { Categories = categories })
                .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "Temperature (°C)" } })
                .SetTooltip(new Tooltip { Enabled = true, Formatter = @"function() { return '<b>'+ this.series.name +'</b><br/>'+ this.x +': '+ this.y +'°C'; }" })
                .SetPlotOptions(new PlotOptions
                {
                    Line = new PlotOptionsLine
                    {
                        DataLabels = new PlotOptionsLineDataLabels
                        {
                            Enabled = true
                        },
                        EnableMouseTracking = false
                    }
                })
                .SetSeries(new[]
                           {
                               new Series { Name = "Tokyo", Data = new Data(tokioData) },
                               new Series { Name = "London", Data = new Data(londonData) }
                           });


            return chart.ToHtmlString(ChartWidth, ChartHeight);

        }


        #region 出账用户数变化情况

        #region 移网出账用户数变化情况-按电信类型
        /// <summary>
        /// 移网出账用户数变化情况-按电信类型
        /// </summary>
        /// <param name="month">需要统计的月份string[] { "201201", "201202", "201203" }</param>
        /// <returns></returns>
        public String ChartESSDeviceCountGroupByMonth(string Dpt, string[] month, out string htmltable)
        {
            Highcharts chart = new Highcharts("chart")
               .InitChart(new Chart { DefaultSeriesType = ChartTypes.Column })
               .SetTitle(new Title { Text = "移网出账用户数变化情况-按电信类型" })
               .SetXAxis(new XAxis { Categories = month })
               .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "合计" } })
               .SetTooltip(new Tooltip { Formatter = "function() { return ''+ this.series.name +': '+ this.point.y +'<br>总计: '+this.point.stackTotal+'<br>占比 '+ this.percentage.toFixed(2) +'%'; }" })

               .SetPlotOptions(new PlotOptions { Column = new PlotOptionsColumn { Stacking = Stackings.Normal } })

               .SetSeries(GetSeriesDeviceCountGroupByMonth(Dpt, month, out htmltable));

            return chart.ToHtmlString(ChartWidth, ChartHeight);
        }
        /// <summary>
        /// 获取纵轴系列
        /// </summary>
        /// <param name="month"></param>
        /// <param name="htmltable"></param>
        /// <returns></returns>
        protected Series[] GetSeriesDeviceCountGroupByMonth(string Dpt, string[] month, out string htmltable)
        {
            htmltable = "<table border=1 align=center id=gvList  width='" + ChartWidth + "px' class=tableborder>";
            string[] types = new string[] { "WCDMA", "OCS3G", "GSM", "OCS2G" };//电信类型
            int[,] nums = new int[types.Length, month.Length];//用二维数组存放计算出来的数据，便于计算列
            Series[] _series = new Series[types.Length];//初始化Y数组

            string sql = "select nvl(sum(t.CHUZHANGYONGHUSHU),0) from ess_chart_yw_ywsrjyhs t WHERE t.BIG_DEPT_NAME='" + Dpt + "' AND t.ZHANGQI='{0}' AND t.TELE_TYPE='{1}' ";

            if (IsDYAdmin)
            {
                sql = sql.Replace("t.BIG_DEPT_NAME='" + Dpt + "' AND", "");//大领导去除公司限制
            }

            int i = 0;//Y数组索引

            #region  表头
            htmltable += "<tr><td>类型\\月份</td>";
            foreach (string m in month)
            {
                htmltable += "<td>" + m + "</td>";
            }
            htmltable += "<td>合计</td></tr>";
            #endregion
            foreach (string stype in types)
            {
                htmltable += "<tr>";
                htmltable += "<td>" + stype + "</td>";
                int y = 0;//数据索引
                int sumrow = 0;//列计算
                object[] _sdata = new object[month.Length];//初始化存放数据的数组
                foreach (string m in month)
                {
                    object count = AdoHelper.ExecuteScalar(string.Format(sql, m, stype));
                    htmltable += "<td>" + count + "</td>";
                    sumrow += Convert.ToInt32(count);
                    
                    _sdata[y] = count;//把数据放入数组
                    nums[i, y] = Convert.ToInt32(count);//放入二维数组，计算列合计
                    //FTchina.Library.LogHelper.Debug(m+stype+_sdata[y]);
                    y += 1;
                }
                _series[i] = new Series { Name = stype, Data = new Data(_sdata) };//组装一条线

                i += 1;
                htmltable += "<td>" + sumrow + "</td>";
                htmltable += "</tr>";
            }
            #region 合计行
            htmltable += "<tr><td>合计</td>";
            int sunmall = 0;//合计所有
            for (int m = 0; m < month.Length; m++)
            {
                int sumcolums = 0;//计算列，从二维数组中计算
                for (int n = 0; n < types.Length; n++)
                {
                    // Library.LogHelper.Debug(m.ToString() + n.ToString() + nums[m, n].ToString());
                    sumcolums += nums[n, m];
                }
                sunmall += sumcolums;//合计所有的列
                htmltable += "<td>" + sumcolums + "</td>";
            }

            htmltable += "<td>" + sunmall + "</td></tr>";
            #endregion

            htmltable += "</table>";
            return _series;
        }



        #endregion

        #region 2G出账用户数变化情况-按电信类型
        /// <summary>
        /// 2G出账用户数变化情况-按电信类型
        /// </summary>
        /// <param name="month">需要统计的月份string[] { "201201", "201202", "201203" }</param>
        /// <returns></returns>
        public String ChartESS2GDeviceCountGroupByMonth(string Dpt, string[] month, out string htmltable)
        {
            Highcharts chart = new Highcharts("chart")
               .InitChart(new Chart { DefaultSeriesType = ChartTypes.Column })
               .SetTitle(new Title { Text = "2G出账用户数变化情况-按电信类型" })
               .SetXAxis(new XAxis { Categories = month })
               .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "合计" } })
               .SetTooltip(new Tooltip { Formatter = "function() { return ''+ this.series.name +': '+ this.point.y +'<br>总计: '+this.point.stackTotal+'<br>占比 '+ this.percentage.toFixed(2) +'%'; }" })

               .SetPlotOptions(new PlotOptions { Column = new PlotOptionsColumn { Stacking = Stackings.Normal } })

               .SetSeries(GetSeries2GDeviceCountGroupByMonth(Dpt, month, out htmltable));

            return chart.ToHtmlString(ChartWidth, ChartHeight);
        }
        /// <summary>
        /// 获取纵轴系列
        /// </summary>
        /// <param name="month"></param>
        /// <param name="htmltable"></param>
        /// <returns></returns>
        protected Series[] GetSeries2GDeviceCountGroupByMonth(string Dpt, string[] month, out string htmltable)
        {
            htmltable = "<table border=1 align=center id=gvList  width='" + ChartWidth + "px' class=tableborder>";
            string[] types = new string[] { "GSM", "OCS2G" };//电信类型
            int[,] nums = new int[types.Length, month.Length];//用二维数组存放计算出来的数据，便于计算列
            Series[] _series = new Series[types.Length];//初始化Y数组

            string sql = "select nvl(sum(t.CHUZHANGYONGHUSHU),0) from ess_chart_yw_ywsrjyhs t WHERE t.BIG_DEPT_NAME='" + Dpt + "' AND t.ZHANGQI='{0}' AND t.TELE_TYPE='{1}' ";

            if (IsDYAdmin)
            {
                sql = sql.Replace("t.BIG_DEPT_NAME='" + Dpt + "' AND", "");//大领导去除公司限制
            }
            int i = 0;//Y数组索引

            #region  表头
            htmltable += "<tr><td>类型\\月份</td>";
            foreach (string m in month)
            {
                htmltable += "<td>" + m + "</td>";
            }
            htmltable += "<td>合计</td></tr>";
            #endregion
            foreach (string stype in types)
            {
                htmltable += "<tr>";
                htmltable += "<td>" + stype + "</td>";
                int y = 0;//数据索引
                int sumrow = 0;//列计算
                object[] _sdata = new object[month.Length];//初始化存放数据的数组
                foreach (string m in month)
                {
                    object count = AdoHelper.ExecuteScalar(string.Format(sql, m, stype));
                    htmltable += "<td>" + count + "</td>";
                    sumrow += Convert.ToInt32(count);
                    _sdata[y] = count;//把数据放入数组
                    nums[i, y] = Convert.ToInt32(count);//放入二维数组，计算列合计
                    //FTchina.Library.LogHelper.Debug(m+stype+_sdata[y]);
                    y += 1;
                }
                _series[i] = new Series { Name = stype, Data = new Data(_sdata) };//组装一条线

                i += 1;
                htmltable += "<td>" + sumrow + "</td>";
                htmltable += "</tr>";
            }
            #region 合计行
            htmltable += "<tr><td>合计</td>";
            int sunmall = 0;//合计所有
            for (int m = 0; m < month.Length; m++)
            {
                int sumcolums = 0;//计算列，从二维数组中计算
                for (int n = 0; n < types.Length; n++)
                {
                    // Library.LogHelper.Debug(m.ToString() + n.ToString() + nums[m, n].ToString());
                    sumcolums += nums[n, m];
                }
                sunmall += sumcolums;//合计所有的列
                htmltable += "<td>" + sumcolums + "</td>";
            }

            htmltable += "<td>" + sunmall + "</td></tr>";
            #endregion

            htmltable += "</table>";
            return _series;
        }



        #endregion
        #region 3G出账用户数变化情况-按电信类型
        /// <summary>
        /// 3G出账用户数变化情况-按电信类型
        /// </summary>
        /// <param name="month">需要统计的月份string[] { "201201", "201202", "201203" }</param>
        /// <returns></returns>
        public String ChartESS3GDeviceCountGroupByMonth(string Dpt, string[] month, out string htmltable)
        {
            Highcharts chart = new Highcharts("chart")
               .InitChart(new Chart { DefaultSeriesType = ChartTypes.Column })
               .SetTitle(new Title { Text = "3G出账用户数变化情况-按电信类型" })
               .SetXAxis(new XAxis { Categories = month })
               .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "合计" } })
               .SetTooltip(new Tooltip { Formatter = "function() { return ''+ this.series.name +': '+ this.point.y +'<br>总计: '+this.point.stackTotal+'<br>占比 '+ this.percentage.toFixed(2) +'%'; }" })

               .SetPlotOptions(new PlotOptions { Column = new PlotOptionsColumn { Stacking = Stackings.Normal } })

               .SetSeries(GetSeries3GDeviceCountGroupByMonth(Dpt, month, out htmltable));

            return chart.ToHtmlString(ChartWidth, ChartHeight);
        }
        /// <summary>
        /// 获取纵轴系列
        /// </summary>
        /// <param name="month"></param>
        /// <param name="htmltable"></param>
        /// <returns></returns>
        protected Series[] GetSeries3GDeviceCountGroupByMonth(string Dpt, string[] month, out string htmltable)
        {
            htmltable = "<table border=1 align=center id=gvList  width='" + ChartWidth + "px' class=tableborder>";
            string[] types = new string[] { "WCDMA", "OCS3G" };//电信类型
            int[,] nums = new int[types.Length, month.Length];//用二维数组存放计算出来的数据，便于计算列
            Series[] _series = new Series[types.Length];//初始化Y数组

            string sql = "select nvl(sum(t.CHUZHANGYONGHUSHU),0) from ess_chart_yw_ywsrjyhs t WHERE t.BIG_DEPT_NAME='" + Dpt + "' AND t.ZHANGQI='{0}' AND t.TELE_TYPE='{1}' ";
            if (IsDYAdmin)
            {
                sql = sql.Replace("t.BIG_DEPT_NAME='" + Dpt + "' AND", "");//大领导去除公司限制
            }
            int i = 0;//Y数组索引

            #region  表头
            htmltable += "<tr><td>类型\\月份</td>";
            foreach (string m in month)
            {
                htmltable += "<td>" + m + "</td>";
            }
            htmltable += "<td>合计</td></tr>";
            #endregion
            foreach (string stype in types)
            {
                htmltable += "<tr>";
                htmltable += "<td>" + stype + "</td>";
                int y = 0;//数据索引
                int sumrow = 0;//列计算
                object[] _sdata = new object[month.Length];//初始化存放数据的数组
                foreach (string m in month)
                {
                    object count = AdoHelper.ExecuteScalar(string.Format(sql, m, stype));
                    htmltable += "<td>" + count + "</td>";
                    sumrow += Convert.ToInt32(count);
                    _sdata[y] = count;//把数据放入数组
                    nums[i, y] = Convert.ToInt32(count);//放入二维数组，计算列合计
                    //FTchina.Library.LogHelper.Debug(m+stype+_sdata[y]);
                    y += 1;
                }
                _series[i] = new Series { Name = stype, Data = new Data(_sdata) };//组装一条线

                i += 1;
                htmltable += "<td>" + sumrow + "</td>";
                htmltable += "</tr>";
            }
            #region 合计行
            htmltable += "<tr><td>合计</td>";
            int sunmall = 0;//合计所有
            for (int m = 0; m < month.Length; m++)
            {
                int sumcolums = 0;//计算列，从二维数组中计算
                for (int n = 0; n < types.Length; n++)
                {
                    // Library.LogHelper.Debug(m.ToString() + n.ToString() + nums[m, n].ToString());
                    sumcolums += nums[n, m];
                }
                sunmall += sumcolums;//合计所有的列
                htmltable += "<td>" + sumcolums + "</td>";
            }

            htmltable += "<td>" + sunmall + "</td></tr>";
            #endregion

            htmltable += "</table>";
            return _series;
        }



        #endregion
        #endregion


        #region 移网收入变化情况

        #region 移网收入变化情况
        /// <summary>
        /// 移网业务收入变化情况
        /// </summary>
        /// <param name="month">需要统计的月份string[] { "201201", "201202", "201203" }</param>
        /// <returns></returns>
        public String ChartESSIncome(string Dpt, string[] month, out string htmltable)
        {
            Highcharts chart = new Highcharts("chart")
               .InitChart(new Chart { DefaultSeriesType = ChartTypes.Column })
               .SetTitle(new Title { Text = "移网收入变化情况-按电信类型" })
               .SetXAxis(new XAxis { Categories = month })
               .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "合计" } })
               .SetTooltip(new Tooltip { Formatter = "function() { return ''+ this.series.name +': '+ this.point.y +'<br>总计: '+this.point.stackTotal+'<br>占比 '+ this.percentage.toFixed(2) +'%'; }" })

               .SetPlotOptions(new PlotOptions { Column = new PlotOptionsColumn { Stacking = Stackings.Normal } })

               .SetSeries(GetSeriesIncome(Dpt, month, out htmltable));

            return chart.ToHtmlString(ChartWidth, ChartHeight);
        }
        /// <summary>
        /// 获取纵轴系列
        /// </summary>
        /// <param name="month"></param>
        /// <param name="htmltable"></param>
        /// <returns></returns>
        protected Series[] GetSeriesIncome(string Dpt, string[] month, out string htmltable)
        {
            htmltable = "<table border=1 align=center id=gvList  width='" + ChartWidth + "px' class=tableborder>";
            string[] types = new string[] { "WCDMA", "OCS3G", "GSM", "OCS2G" };//电信类型
            int[,] nums = new int[types.Length, month.Length];//用二维数组存放计算出来的数据，便于计算列
            Series[] _series = new Series[types.Length];//初始化Y数组

            // string sql = "SELECT COUNT(s.DEVICE_NUMBER)  FROM  WUWEI75.ww_scbjt_shr_{0} s WHERE s.BIG_DEPT_NAME='" + Dpt + "' AND s.TELE_TYPE='{1}'";

            string sql = "select nvl(sum(jingyingshou),0) from ess_chart_yw_ywsrjyhs t WHERE t.BIG_DEPT_NAME='" + Dpt + "' AND t.ZHANGQI='{0}' AND t.TELE_TYPE='{1}' ";
            if (IsDYAdmin)
            {
                sql = sql.Replace("t.BIG_DEPT_NAME='" + Dpt + "' AND", "");//大领导去除公司限制
            }
            int i = 0;//Y数组索引

            #region  表头
            htmltable += "<tr><td>类型\\月份</td>";
            foreach (string m in month)
            {
                htmltable += "<td>" + m + "</td>";
            }
            htmltable += "<td>合计</td></tr>";
            #endregion
            foreach (string stype in types)
            {
                htmltable += "<tr>";
                htmltable += "<td>" + stype + "</td>";
                int y = 0;//数据索引
                int sumrow = 0;//列计算
                object[] _sdata = new object[month.Length];//初始化存放数据的数组
                foreach (string m in month)
                {
                    object count = AdoHelper.ExecuteScalar(string.Format(sql, m, stype));
                    htmltable += "<td>" + count + "</td>";
                    sumrow += Convert.ToInt32(count);
                    _sdata[y] = count;//把数据放入数组
                    nums[i, y] = Convert.ToInt32(count);//放入二维数组，计算列合计
                    //FTchina.Library.LogHelper.Debug(m+stype+_sdata[y]);
                    y += 1;
                }
                _series[i] = new Series { Name = stype, Data = new Data(_sdata) };//组装一条线

                i += 1;
                htmltable += "<td>" + sumrow + "</td>";
                htmltable += "</tr>";
            }
            #region 合计行
            htmltable += "<tr><td>合计</td>";
            int sunmall = 0;//合计所有
            for (int m = 0; m < month.Length; m++)
            {
                int sumcolums = 0;//计算列，从二维数组中计算
                for (int n = 0; n < types.Length; n++)
                {
                    // Library.LogHelper.Debug(m.ToString() + n.ToString() + nums[m, n].ToString());
                    sumcolums += nums[n, m];
                }
                sunmall += sumcolums;//合计所有的列
                htmltable += "<td>" + sumcolums + "</td>";
            }

            htmltable += "<td>" + sunmall + "</td></tr>";
            #endregion

            htmltable += "</table>";
            return _series;
        }

        #endregion
        #region 2G收入变化情况
        /// <summary>
        /// 移网业务收入变化情况
        /// </summary>
        /// <param name="month">需要统计的月份string[] { "201201", "201202", "201203" }</param>
        /// <returns></returns>
        public String ChartESS2GIncome(string Dpt, string[] month, out string htmltable)
        {
            Highcharts chart = new Highcharts("chart")
               .InitChart(new Chart { DefaultSeriesType = ChartTypes.Column })
               .SetTitle(new Title { Text = "2G收入变化情况-按电信类型" })
               .SetXAxis(new XAxis { Categories = month })
               .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "合计" } })
               .SetTooltip(new Tooltip { Formatter = "function() { return ''+ this.series.name +': '+ this.point.y +'<br>总计: '+this.point.stackTotal+'<br>占比 '+ this.percentage.toFixed(2) +'%'; }" })

               .SetPlotOptions(new PlotOptions { Column = new PlotOptionsColumn { Stacking = Stackings.Normal } })

               .SetSeries(GetSeries2GIncome(Dpt, month, out htmltable));

            return chart.ToHtmlString(ChartWidth, ChartHeight);
        }
        /// <summary>
        /// 获取纵轴系列
        /// </summary>
        /// <param name="month"></param>
        /// <param name="htmltable"></param>
        /// <returns></returns>
        protected Series[] GetSeries2GIncome(string Dpt, string[] month, out string htmltable)
        {
            htmltable = "<table border=1 align=center id=gvList  width='" + ChartWidth + "px' class=tableborder>";
            string[] types = new string[] { "GSM", "OCS2G" };//电信类型
            int[,] nums = new int[types.Length, month.Length];//用二维数组存放计算出来的数据，便于计算列
            Series[] _series = new Series[types.Length];//初始化Y数组

            // string sql = "SELECT COUNT(s.DEVICE_NUMBER)  FROM  WUWEI75.ww_scbjt_shr_{0} s WHERE s.BIG_DEPT_NAME='" + Dpt + "' AND s.TELE_TYPE='{1}'";

            string sql = "select nvl(sum(jingyingshou),0) from ess_chart_yw_ywsrjyhs t WHERE t.BIG_DEPT_NAME='" + Dpt + "' AND t.ZHANGQI='{0}' AND t.TELE_TYPE='{1}' ";
            if (IsDYAdmin)
            {
                sql = sql.Replace("t.BIG_DEPT_NAME='" + Dpt + "' AND", "");//大领导去除公司限制
            }
            int i = 0;//Y数组索引

            #region  表头
            htmltable += "<tr><td>类型\\月份</td>";
            foreach (string m in month)
            {
                htmltable += "<td>" + m + "</td>";
            }
            htmltable += "<td>合计</td></tr>";
            #endregion
            foreach (string stype in types)
            {
                htmltable += "<tr>";
                htmltable += "<td>" + stype + "</td>";
                int y = 0;//数据索引
                int sumrow = 0;//列计算
                object[] _sdata = new object[month.Length];//初始化存放数据的数组
                foreach (string m in month)
                {
                    object count = AdoHelper.ExecuteScalar(string.Format(sql, m, stype));
                    htmltable += "<td>" + count + "</td>";
                    sumrow += Convert.ToInt32(count);
                    _sdata[y] = count;//把数据放入数组
                    nums[i, y] = Convert.ToInt32(count);//放入二维数组，计算列合计
                    //FTchina.Library.LogHelper.Debug(m+stype+_sdata[y]);
                    y += 1;
                }
                _series[i] = new Series { Name = stype, Data = new Data(_sdata) };//组装一条线

                i += 1;
                htmltable += "<td>" + sumrow + "</td>";
                htmltable += "</tr>";
            }
            #region 合计行
            htmltable += "<tr><td>合计</td>";
            int sunmall = 0;//合计所有
            for (int m = 0; m < month.Length; m++)
            {
                int sumcolums = 0;//计算列，从二维数组中计算
                for (int n = 0; n < types.Length; n++)
                {
                    // Library.LogHelper.Debug(m.ToString() + n.ToString() + nums[m, n].ToString());
                    sumcolums += nums[n, m];
                }
                sunmall += sumcolums;//合计所有的列
                htmltable += "<td>" + sumcolums + "</td>";
            }

            htmltable += "<td>" + sunmall + "</td></tr>";
            #endregion

            htmltable += "</table>";
            return _series;
        }

        #endregion
        #region 2G收入变化情况
        /// <summary>
        /// 移网业务收入变化情况
        /// </summary>
        /// <param name="month">需要统计的月份string[] { "201201", "201202", "201203" }</param>
        /// <returns></returns>
        public String ChartESS3GIncome(string Dpt, string[] month, out string htmltable)
        {
            Highcharts chart = new Highcharts("chart")
               .InitChart(new Chart { DefaultSeriesType = ChartTypes.Column })
               .SetTitle(new Title { Text = "3G收入变化情况-按电信类型" })
               .SetXAxis(new XAxis { Categories = month })
               .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "合计" } })
               .SetTooltip(new Tooltip { Formatter = "function() { return ''+ this.series.name +': '+ this.point.y +'<br>总计: '+this.point.stackTotal+'<br>占比 '+ this.percentage.toFixed(2) +'%'; }" })

               .SetPlotOptions(new PlotOptions { Column = new PlotOptionsColumn { Stacking = Stackings.Normal } })

               .SetSeries(GetSeries3GIncome(Dpt, month, out htmltable));

            return chart.ToHtmlString(ChartWidth, ChartHeight);
        }
        /// <summary>
        /// 获取纵轴系列
        /// </summary>
        /// <param name="month"></param>
        /// <param name="htmltable"></param>
        /// <returns></returns>
        protected Series[] GetSeries3GIncome(string Dpt, string[] month, out string htmltable)
        {
            htmltable = "<table border=1 align=center id=gvList  width='" + ChartWidth + "px' class=tableborder>";
            string[] types = new string[] { "WCDMA", "OCS3G" };//电信类型
            int[,] nums = new int[types.Length, month.Length];//用二维数组存放计算出来的数据，便于计算列
            Series[] _series = new Series[types.Length];//初始化Y数组

            // string sql = "SELECT COUNT(s.DEVICE_NUMBER)  FROM  WUWEI75.ww_scbjt_shr_{0} s WHERE s.BIG_DEPT_NAME='" + Dpt + "' AND s.TELE_TYPE='{1}'";

            string sql = "select nvl(sum(jingyingshou),0) from ess_chart_yw_ywsrjyhs t WHERE t.BIG_DEPT_NAME='" + Dpt + "' AND t.ZHANGQI='{0}' AND t.TELE_TYPE='{1}' ";
            if (IsDYAdmin)
            {
                sql = sql.Replace("t.BIG_DEPT_NAME='" + Dpt + "' AND", "");//大领导去除公司限制
            }
            int i = 0;//Y数组索引

            #region  表头
            htmltable += "<tr><td>类型\\月份</td>";
            foreach (string m in month)
            {
                htmltable += "<td>" + m + "</td>";
            }
            htmltable += "<td>合计</td></tr>";
            #endregion
            foreach (string stype in types)
            {
                htmltable += "<tr>";
                htmltable += "<td>" + stype + "</td>";
                int y = 0;//数据索引
                int sumrow = 0;//列计算
                object[] _sdata = new object[month.Length];//初始化存放数据的数组
                foreach (string m in month)
                {
                    object count = AdoHelper.ExecuteScalar(string.Format(sql, m, stype));
                    htmltable += "<td>" + count + "</td>";
                    sumrow += Convert.ToInt32(count);
                    _sdata[y] = count;//把数据放入数组
                    nums[i, y] = Convert.ToInt32(count);//放入二维数组，计算列合计
                    //FTchina.Library.LogHelper.Debug(m+stype+_sdata[y]);
                    y += 1;
                }
                _series[i] = new Series { Name = stype, Data = new Data(_sdata) };//组装一条线

                i += 1;
                htmltable += "<td>" + sumrow + "</td>";
                htmltable += "</tr>";
            }
            #region 合计行
            htmltable += "<tr><td>合计</td>";
            int sunmall = 0;//合计所有
            for (int m = 0; m < month.Length; m++)
            {
                int sumcolums = 0;//计算列，从二维数组中计算
                for (int n = 0; n < types.Length; n++)
                {
                    // Library.LogHelper.Debug(m.ToString() + n.ToString() + nums[m, n].ToString());
                    sumcolums += nums[n, m];
                }
                sunmall += sumcolums;//合计所有的列
                htmltable += "<td>" + sumcolums + "</td>";
            }

            htmltable += "<td>" + sunmall + "</td></tr>";
            #endregion

            htmltable += "</table>";
            return _series;
        }

        #endregion
        #endregion


        #region 收入及用户数变化情况

        #region 移网业务收入及用户数变化情况

        /// <summary>
        /// 移网业务收入变化情况
        /// </summary>
        /// <param name="month">需要统计的月份string[] { "201201", "201202", "201203" }</param>
        /// <returns></returns>
        public String ChartESSIncomeWithUserCount(string Dpt, string[] month, out string htmltable)
        {
            Highcharts chart = new Highcharts("chart")
               .InitChart(new Chart { DefaultSeriesType = ChartTypes.Line })
               .SetTitle(new Title { Text = "移网业务收入及用户数变化情况" })
               .SetXAxis(new XAxis { Categories = month })
               .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "合计" } })
               .SetTooltip(new Tooltip { Formatter = "function() { return ''+ this.series.name +': '+ this.y; }" })

               .SetPlotOptions(new PlotOptions { Column = new PlotOptionsColumn { Stacking = Stackings.Normal } })

               .SetSeries(GetSeriesIncomeWithUserCount(Dpt, month, out htmltable));

            return chart.ToHtmlString(ChartWidth, ChartHeight);
        }
        /// <summary>
        /// 获取纵轴系列
        /// </summary>
        /// <param name="month"></param>
        /// <param name="htmltable"></param>
        /// <returns></returns>
        protected Series[] GetSeriesIncomeWithUserCount(string Dpt, string[] month, out string htmltable)
        {
            htmltable = "<table border=1 align=center id=gvList  width='" + ChartWidth + "px' class=tableborder>";
            string[] types = new string[] { "移网净应收", "移网出账用户数" };//统计类型
            int[,] nums = new int[types.Length, month.Length];//用二维数组存放计算出来的数据，便于计算列
            Series[] _series = new Series[types.Length];//初始化Y数组

            // string sql = "SELECT COUNT(s.DEVICE_NUMBER)  FROM  WUWEI75.ww_scbjt_shr_{0} s WHERE s.BIG_DEPT_NAME='" + Dpt + "' AND s.TELE_TYPE='{1}'";

            //净应收
            string sqljys = "select nvl(sum(jingyingshou),0) from ess_chart_yw_ywsrjyhs t WHERE t.BIG_DEPT_NAME='" + Dpt + "' AND t.ZHANGQI='{0}' AND t.TELE_TYPE='all' ";
            //出账用户数
            string sqlczyhs = "select nvl(sum(CHUZHANGYONGHUSHU),0) from ess_chart_yw_ywsrjyhs t WHERE t.BIG_DEPT_NAME='" + Dpt + "' AND t.ZHANGQI='{0}' AND t.TELE_TYPE='all' ";

            if (IsDYAdmin)
            {
                sqljys = sqljys.Replace("t.BIG_DEPT_NAME='" + Dpt + "' AND", "");//大领导去除公司限制
                sqlczyhs = sqlczyhs.Replace("t.BIG_DEPT_NAME='" + Dpt + "' AND", "");//大领导去除公司限制
            }

            int i = 0;//Y数组索引

            #region  表头
            htmltable += "<tr><td>类型\\月份</td>";
            foreach (string m in month)
            {
                htmltable += "<td>" + m + "</td>";
            }
            htmltable += "<td>合计</td></tr>";
            #endregion
            foreach (string stype in types)
            {
                htmltable += "<tr>";
                htmltable += "<td>" + stype + "</td>";
                int y = 0;//数据索引
                int sumrow = 0;//列计算
                object[] _sdata = new object[month.Length];//初始化存放数据的数组
                foreach (string m in month)
                {
                    object count = (stype == "移网净应收") ? AdoHelper.ExecuteScalar(string.Format(sqljys, m)) : AdoHelper.ExecuteScalar(string.Format(sqlczyhs, m));
                    htmltable += "<td>" + count + "</td>";
                    sumrow += Convert.ToInt32(count);
                    _sdata[y] = count;//把数据放入数组
                    nums[i, y] = Convert.ToInt32(count);//放入二维数组，计算列合计
                    //FTchina.Library.LogHelper.Debug(m+stype+_sdata[y]);
                    y += 1;
                }
                _series[i] = new Series { Name = stype, Data = new Data(_sdata) };//组装一条线

                i += 1;
                htmltable += "<td>" + sumrow + "</td>";
                htmltable += "</tr>";
            }
            #region 合计行
            //htmltable += "<tr><td>合计</td>";
            //int sunmall = 0;//合计所有
            //for (int m = 0; m < month.Length; m++)
            //{
            //    int sumcolums = 0;//计算列，从二维数组中计算
            //    for (int n = 0; n < types.Length; n++)
            //    {
            //        // Library.LogHelper.Debug(m.ToString() + n.ToString() + nums[m, n].ToString());
            //        sumcolums += nums[n, m];
            //    }
            //    sunmall += sumcolums;//合计所有的列
            //    htmltable += "<td>" + sumcolums + "</td>";
            //}

            //htmltable += "<td>" + sunmall + "</td></tr>";
            #endregion

            htmltable += "</table>";
            return _series;
        }

        #endregion
        #region 2G业务收入及用户数变化情况

        /// <summary>
        /// 移网业务收入变化情况
        /// </summary>
        /// <param name="month">需要统计的月份string[] { "201201", "201202", "201203" }</param>
        /// <returns></returns>
        public String ChartESS2GIncomeWithUserCount(string Dpt, string[] month, out string htmltable)
        {
            Highcharts chart = new Highcharts("chart")
               .InitChart(new Chart { DefaultSeriesType = ChartTypes.Line })
               .SetTitle(new Title { Text = "2G收入及用户数变化情况" })
               .SetXAxis(new XAxis { Categories = month })
               .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "合计" } })
               .SetTooltip(new Tooltip { Formatter = "function() { return ''+ this.series.name +': '+ this.y; }" })

               .SetPlotOptions(new PlotOptions { Column = new PlotOptionsColumn { Stacking = Stackings.Normal } })

               .SetSeries(GetSeries2GIncomeWithUserCount(Dpt, month, out htmltable));

            return chart.ToHtmlString(ChartWidth, ChartHeight);
        }
        /// <summary>
        /// 获取纵轴系列
        /// </summary>
        /// <param name="month"></param>
        /// <param name="htmltable"></param>
        /// <returns></returns>
        protected Series[] GetSeries2GIncomeWithUserCount(string Dpt, string[] month, out string htmltable)
        {
            htmltable = "<table border=1 align=center id=gvList  width='" + ChartWidth + "px' class=tableborder>";
            string[] types = new string[] { "2G净应收", "2G出账用户数" };//统计类型
            int[,] nums = new int[types.Length, month.Length];//用二维数组存放计算出来的数据，便于计算列
            Series[] _series = new Series[types.Length];//初始化Y数组

            // string sql = "SELECT COUNT(s.DEVICE_NUMBER)  FROM  WUWEI75.ww_scbjt_shr_{0} s WHERE s.BIG_DEPT_NAME='" + Dpt + "' AND s.TELE_TYPE='{1}'";

            //净应收
            string sqljys = "select nvl(sum(jingyingshou),0) from ess_chart_yw_ywsrjyhs t WHERE t.BIG_DEPT_NAME='" + Dpt + "' AND t.ZHANGQI='{0}' AND ( t.TELE_TYPE='GSM' OR t.TELE_TYPE='OCS2G')";
            //出账用户数
            string sqlczyhs = "select nvl(sum(CHUZHANGYONGHUSHU),0) from ess_chart_yw_ywsrjyhs t WHERE t.BIG_DEPT_NAME='" + Dpt + "' AND t.ZHANGQI='{0}' AND ( t.TELE_TYPE='GSM' OR t.TELE_TYPE='OCS2G')";

            if (IsDYAdmin)
            {
                sqljys = sqljys.Replace("t.BIG_DEPT_NAME='" + Dpt + "' AND", "");//大领导去除公司限制
                sqlczyhs = sqlczyhs.Replace("t.BIG_DEPT_NAME='" + Dpt + "' AND", "");//大领导去除公司限制
            }


            int i = 0;//Y数组索引

            #region  表头
            htmltable += "<tr><td>类型\\月份</td>";
            foreach (string m in month)
            {
                htmltable += "<td>" + m + "</td>";
            }
            htmltable += "<td>合计</td></tr>";
            #endregion
            foreach (string stype in types)
            {
                htmltable += "<tr>";
                htmltable += "<td>" + stype + "</td>";
                int y = 0;//数据索引
                int sumrow = 0;//列计算
                object[] _sdata = new object[month.Length];//初始化存放数据的数组
                foreach (string m in month)
                {
                    object count = (stype == "2G净应收") ? AdoHelper.ExecuteScalar(string.Format(sqljys, m)) : AdoHelper.ExecuteScalar(string.Format(sqlczyhs, m));
                    htmltable += "<td>" + count + "</td>";
                    sumrow += Convert.ToInt32(count);
                    _sdata[y] = count;//把数据放入数组
                    nums[i, y] = Convert.ToInt32(count);//放入二维数组，计算列合计
                    //FTchina.Library.LogHelper.Debug(m+stype+_sdata[y]);
                    y += 1;
                }
                _series[i] = new Series { Name = stype, Data = new Data(_sdata) };//组装一条线

                i += 1;
                htmltable += "<td>" + sumrow + "</td>";
                htmltable += "</tr>";
            }
            #region 合计行
            //htmltable += "<tr><td>合计</td>";
            //int sunmall = 0;//合计所有
            //for (int m = 0; m < month.Length; m++)
            //{
            //    int sumcolums = 0;//计算列，从二维数组中计算
            //    for (int n = 0; n < types.Length; n++)
            //    {
            //        // Library.LogHelper.Debug(m.ToString() + n.ToString() + nums[m, n].ToString());
            //        sumcolums += nums[n, m];
            //    }
            //    sunmall += sumcolums;//合计所有的列
            //    htmltable += "<td>" + sumcolums + "</td>";
            //}

            //htmltable += "<td>" + sunmall + "</td></tr>";
            #endregion

            htmltable += "</table>";
            return _series;
        }

        #endregion
        #region 3G业务收入及用户数变化情况

        /// <summary>
        /// 移网业务收入变化情况
        /// </summary>
        /// <param name="month">需要统计的月份string[] { "201201", "201202", "201203" }</param>
        /// <returns></returns>
        public String ChartESS3GIncomeWithUserCount(string Dpt, string[] month, out string htmltable)
        {
            Highcharts chart = new Highcharts("chart")
               .InitChart(new Chart { DefaultSeriesType = ChartTypes.Line })
               .SetTitle(new Title { Text = "3G收入及用户数变化情况" })
               .SetXAxis(new XAxis { Categories = month })
               .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "合计" } })
               .SetTooltip(new Tooltip { Formatter = "function() { return ''+ this.series.name +': '+ this.y; }" })

               .SetPlotOptions(new PlotOptions { Column = new PlotOptionsColumn { Stacking = Stackings.Normal } })

               .SetSeries(GetSeries3GIncomeWithUserCount(Dpt, month, out htmltable));

            return chart.ToHtmlString(ChartWidth, ChartHeight);
        }
        /// <summary>
        /// 获取纵轴系列
        /// </summary>
        /// <param name="month"></param>
        /// <param name="htmltable"></param>
        /// <returns></returns>
        protected Series[] GetSeries3GIncomeWithUserCount(string Dpt, string[] month, out string htmltable)
        {
            htmltable = "<table border=1 align=center id=gvList  width='" + ChartWidth + "px' class=tableborder>";
            string[] types = new string[] { "3G净应收", "3G出账用户数" };//统计类型
            int[,] nums = new int[types.Length, month.Length];//用二维数组存放计算出来的数据，便于计算列
            Series[] _series = new Series[types.Length];//初始化Y数组

            // string sql = "SELECT COUNT(s.DEVICE_NUMBER)  FROM  WUWEI75.ww_scbjt_shr_{0} s WHERE s.BIG_DEPT_NAME='" + Dpt + "' AND s.TELE_TYPE='{1}'";

            //净应收
            string sqljys = "select nvl(sum(jingyingshou),0) from ess_chart_yw_ywsrjyhs t WHERE t.BIG_DEPT_NAME='" + Dpt + "' AND t.ZHANGQI='{0}' AND ( t.TELE_TYPE='WCDMA' OR t.TELE_TYPE='OCS3G')";
            //出账用户数
            string sqlczyhs = "select nvl(sum(CHUZHANGYONGHUSHU),0) from ess_chart_yw_ywsrjyhs t WHERE t.BIG_DEPT_NAME='" + Dpt + "' AND t.ZHANGQI='{0}' AND ( t.TELE_TYPE='WCDMA' OR t.TELE_TYPE='OCS3G')";

            if (IsDYAdmin)
            {
                sqljys = sqljys.Replace("t.BIG_DEPT_NAME='" + Dpt + "' AND", "");//大领导去除公司限制
                sqlczyhs = sqlczyhs.Replace("t.BIG_DEPT_NAME='" + Dpt + "' AND", "");//大领导去除公司限制
            }

            int i = 0;//Y数组索引

            #region  表头
            htmltable += "<tr><td>类型\\月份</td>";
            foreach (string m in month)
            {
                htmltable += "<td>" + m + "</td>";
            }
            htmltable += "<td>合计</td></tr>";
            #endregion
            foreach (string stype in types)
            {
                htmltable += "<tr>";
                htmltable += "<td>" + stype + "</td>";
                int y = 0;//数据索引
                int sumrow = 0;//列计算
                object[] _sdata = new object[month.Length];//初始化存放数据的数组
                foreach (string m in month)
                {
                    object count = (stype == "3G净应收") ? AdoHelper.ExecuteScalar(string.Format(sqljys, m)) : AdoHelper.ExecuteScalar(string.Format(sqlczyhs, m));
                    htmltable += "<td>" + count + "</td>";
                    sumrow += Convert.ToInt32(count);
                    _sdata[y] = count;//把数据放入数组
                    nums[i, y] = Convert.ToInt32(count);//放入二维数组，计算列合计
                    //FTchina.Library.LogHelper.Debug(m+stype+_sdata[y]);
                    y += 1;
                }
                _series[i] = new Series { Name = stype, Data = new Data(_sdata) };//组装一条线

                i += 1;
                htmltable += "<td>" + sumrow + "</td>";
                htmltable += "</tr>";
            }
            #region 合计行
            //htmltable += "<tr><td>合计</td>";
            //int sunmall = 0;//合计所有
            //for (int m = 0; m < month.Length; m++)
            //{
            //    int sumcolums = 0;//计算列，从二维数组中计算
            //    for (int n = 0; n < types.Length; n++)
            //    {
            //        // Library.LogHelper.Debug(m.ToString() + n.ToString() + nums[m, n].ToString());
            //        sumcolums += nums[n, m];
            //    }
            //    sunmall += sumcolums;//合计所有的列
            //    htmltable += "<td>" + sumcolums + "</td>";
            //}

            //htmltable += "<td>" + sunmall + "</td></tr>";
            #endregion

            htmltable += "</table>";
            return _series;
        }

        #endregion

        #endregion


        #region 按收入来源收入及用户数变化情况

        #region 按收入来源移网收入变化情况
        /// <summary>
        /// 移网收入变化情况-按收入来源
        /// </summary>
        /// <param name="month">需要统计的月份string[] { "201201", "201202", "201203" }</param>
        /// <returns></returns>
        public String ChartESSIncomeBySource(string Dpt, string[] month, out string htmltable)
        {
            Highcharts chart = new Highcharts("chart")
               .InitChart(new Chart { DefaultSeriesType = ChartTypes.Column })
               .SetTitle(new Title { Text = "移网收入变化情况-按收入来源" })
               .SetXAxis(new XAxis { Categories = month })
               .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "合计" } })
               .SetTooltip(new Tooltip { Formatter = "function() { return ''+ this.series.name +': '+ this.point.y +'<br>总计: '+this.point.stackTotal+'<br>占比 '+ this.percentage.toFixed(2) +'%'; }" })

               .SetPlotOptions(new PlotOptions { Column = new PlotOptionsColumn { Stacking = Stackings.Normal } })

               .SetSeries(GetSeriesIncomeBySource(Dpt, month, out htmltable));

            return chart.ToHtmlString(ChartWidth, ChartHeight);
        }
        /// <summary>
        /// 获取纵轴系列
        /// </summary>
        /// <param name="month"></param>
        /// <param name="htmltable"></param>
        /// <returns></returns>
        protected Series[] GetSeriesIncomeBySource(string Dpt, string[] month, out string htmltable)
        {
            htmltable = "<table border=1 align=center id=gvList  width='" + ChartWidth + "px' class=tableborder>";
            string[] types = new string[] { "集团落地", "自有" };//电信类型
            int[,] nums = new int[types.Length, month.Length];//用二维数组存放计算出来的数据，便于计算列
            Series[] _series = new Series[types.Length];//初始化Y数组

            string sqlziyou = "select nvl(SUM(shouru ),0) from ess_chart_yw_srly t WHERE t.BIG_DEPT_NAME='" + Dpt + "' AND t.ZHANGQI='{0}'AND t.USER_TYPE='sh'";
            string sqljituan = "select nvl(SUM(shouru ),0) from ess_chart_yw_srly t WHERE t.BIG_DEPT_NAME='" + Dpt + "' AND t.ZHANGQI='{0}'AND t.USER_TYPE<>'sh'";

            if (IsDYAdmin)
            {
                sqlziyou = sqlziyou.Replace("t.BIG_DEPT_NAME='" + Dpt + "' AND", "");//大领导去除公司限制
                sqljituan = sqljituan.Replace("t.BIG_DEPT_NAME='" + Dpt + "' AND", "");//大领导去除公司限制
            }

            int i = 0;//Y数组索引

            #region  表头
            htmltable += "<tr><td>类型\\月份</td>";
            foreach (string m in month)
            {
                htmltable += "<td>" + m + "</td>";
            }
            htmltable += "<td>合计</td></tr>";
            #endregion
            foreach (string stype in types)
            {
                htmltable += "<tr>";
                htmltable += "<td>" + stype + "</td>";
                int y = 0;//数据索引
                int sumrow = 0;//列计算
                object[] _sdata = new object[month.Length];//初始化存放数据的数组
                foreach (string m in month)
                {
                    object count = (stype == "自有") ? AdoHelper.ExecuteScalar(string.Format(sqlziyou, m)) : AdoHelper.ExecuteScalar(string.Format(sqljituan, m));
                    htmltable += "<td>" + count + "</td>";
                    sumrow += Convert.ToInt32(count);
                    _sdata[y] = count;//把数据放入数组
                    nums[i, y] = Convert.ToInt32(count);//放入二维数组，计算列合计
                    //FTchina.Library.LogHelper.Debug(m+stype+_sdata[y]);
                    y += 1;
                }
                _series[i] = new Series { Name = stype, Data = new Data(_sdata) };//组装一条线

                i += 1;
                htmltable += "<td>" + sumrow + "</td>";
                htmltable += "</tr>";
            }
            #region 合计行
            htmltable += "<tr><td>合计</td>";
            int sunmall = 0;//合计所有
            for (int m = 0; m < month.Length; m++)
            {
                int sumcolums = 0;//计算列，从二维数组中计算
                for (int n = 0; n < types.Length; n++)
                {
                    // Library.LogHelper.Debug(m.ToString() + n.ToString() + nums[m, n].ToString());
                    sumcolums += nums[n, m];
                }
                sunmall += sumcolums;//合计所有的列
                htmltable += "<td>" + sumcolums + "</td>";
            }

            htmltable += "<td>" + sunmall + "</td></tr>";
            #endregion

            htmltable += "</table>";
            return _series;
        }
        #endregion

        #region 按收入来源移网出账用户数变化情况
        /// <summary>
        /// 移网用户数变化情况-按收入来源
        /// </summary>
        /// <param name="month">需要统计的月份string[] { "201201", "201202", "201203" }</param>
        /// <returns></returns>
        public String ChartESSUserCountBySource(string Dpt, string[] month, out string htmltable)
        {
            Highcharts chart = new Highcharts("chart")
               .InitChart(new Chart { DefaultSeriesType = ChartTypes.Column })
               .SetTitle(new Title { Text = "移网用户数变化情况-按收入来源" })
               .SetXAxis(new XAxis { Categories = month })
               .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "合计" } })
               .SetTooltip(new Tooltip { Formatter = "function() { return ''+ this.series.name +': '+ this.point.y +'<br>总计: '+this.point.stackTotal+'<br>占比 '+ this.percentage.toFixed(2) +'%'; }" })

               .SetPlotOptions(new PlotOptions { Column = new PlotOptionsColumn { Stacking = Stackings.Normal } })

               .SetSeries(GetSeriesUserCountBySource(Dpt, month, out htmltable));

            return chart.ToHtmlString(ChartWidth, ChartHeight);
        }
        /// <summary>
        /// 获取纵轴系列
        /// </summary>
        /// <param name="month"></param>
        /// <param name="htmltable"></param>
        /// <returns></returns>
        protected Series[] GetSeriesUserCountBySource(string Dpt, string[] month, out string htmltable)
        {
            htmltable = "<table border=1 align=center id=gvList  width='" + ChartWidth + "px' class=tableborder>";
            string[] types = new string[] { "集团落地", "自有" };//电信类型
            int[,] nums = new int[types.Length, month.Length];//用二维数组存放计算出来的数据，便于计算列
            Series[] _series = new Series[types.Length];//初始化Y数组

            string sqlziyou = "select nvl(SUM(yonghushu),0) from ess_chart_yw_srly t WHERE t.BIG_DEPT_NAME='" + Dpt + "' AND t.ZHANGQI='{0}'AND t.USER_TYPE='sh'";
            string sqljituan = "select nvl(SUM(yonghushu),0) from ess_chart_yw_srly t WHERE t.BIG_DEPT_NAME='" + Dpt + "' AND t.ZHANGQI='{0}'AND t.USER_TYPE<>'sh'";

            if (IsDYAdmin)
            {
                sqlziyou = sqlziyou.Replace("t.BIG_DEPT_NAME='" + Dpt + "' AND", "");//大领导去除公司限制
                sqljituan = sqljituan.Replace("t.BIG_DEPT_NAME='" + Dpt + "' AND", "");//大领导去除公司限制
            }

            int i = 0;//Y数组索引

            #region  表头
            htmltable += "<tr><td>类型\\月份</td>";
            foreach (string m in month)
            {
                htmltable += "<td>" + m + "</td>";
            }
            htmltable += "<td>合计</td></tr>";
            #endregion
            foreach (string stype in types)
            {
                htmltable += "<tr>";
                htmltable += "<td>" + stype + "</td>";
                int y = 0;//数据索引
                int sumrow = 0;//列计算
                object[] _sdata = new object[month.Length];//初始化存放数据的数组
                foreach (string m in month)
                {
                    object count = (stype == "自有") ? AdoHelper.ExecuteScalar(string.Format(sqlziyou, m)) : AdoHelper.ExecuteScalar(string.Format(sqljituan, m));
                    htmltable += "<td>" + count + "</td>";
                    sumrow += Convert.ToInt32(count);
                    _sdata[y] = count;//把数据放入数组
                    nums[i, y] = Convert.ToInt32(count);//放入二维数组，计算列合计
                    //FTchina.Library.LogHelper.Debug(m+stype+_sdata[y]);
                    y += 1;
                }
                _series[i] = new Series { Name = stype, Data = new Data(_sdata) };//组装一条线

                i += 1;
                htmltable += "<td>" + sumrow + "</td>";
                htmltable += "</tr>";
            }
            #region 合计行
            htmltable += "<tr><td>合计</td>";
            int sunmall = 0;//合计所有
            for (int m = 0; m < month.Length; m++)
            {
                int sumcolums = 0;//计算列，从二维数组中计算
                for (int n = 0; n < types.Length; n++)
                {
                    // Library.LogHelper.Debug(m.ToString() + n.ToString() + nums[m, n].ToString());
                    sumcolums += nums[n, m];
                }
                sunmall += sumcolums;//合计所有的列
                htmltable += "<td>" + sumcolums + "</td>";
            }

            htmltable += "<td>" + sunmall + "</td></tr>";
            #endregion

            htmltable += "</table>";
            return _series;
        }
        #endregion

        #endregion



        #region 固网

        #region 固网收入及用户数变化情况

        /// <summary>
        /// 固网收入及用户数变化情况
        /// </summary>
        /// <param name="month">需要统计的月份string[] { "201201", "201202", "201203" }</param>
        /// <returns></returns>
        public String ChartESSGWIncomeWithUserCount(string Dpt, string[] month, out string htmltable)
        {
            Highcharts chart = new Highcharts("chart")
               .InitChart(new Chart { DefaultSeriesType = ChartTypes.Line })
               .SetTitle(new Title { Text = "固网收入及用户数变化情况" })
               .SetXAxis(new XAxis { Categories = month })
               .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "合计" } })
               .SetTooltip(new Tooltip { Formatter = "function() { return ''+ this.series.name +': '+ this.y; }" })

               .SetPlotOptions(new PlotOptions { Column = new PlotOptionsColumn { Stacking = Stackings.Normal } })

               .SetSeries(GetSeriesGWIncomeWithUserCount(Dpt, month, out htmltable));

            return chart.ToHtmlString(ChartWidth, ChartHeight);
        }
        /// <summary>
        /// 获取纵轴系列
        /// </summary>
        /// <param name="month"></param>
        /// <param name="htmltable"></param>
        /// <returns></returns>
        protected Series[] GetSeriesGWIncomeWithUserCount(string Dpt, string[] month, out string htmltable)
        {
            htmltable = "<table border=1 align=center id=gvList  width='" + ChartWidth + "px' class=tableborder>";
            string[] types = new string[] { "固网收入", "固网用户数" };//统计类型
            int[,] nums = new int[types.Length, month.Length];//用二维数组存放计算出来的数据，便于计算列
            Series[] _series = new Series[types.Length];//初始化Y数组

            // string sql = "SELECT COUNT(s.DEVICE_NUMBER)  FROM  WUWEI75.ww_scbjt_shr_{0} s WHERE s.BIG_DEPT_NAME='" + Dpt + "' AND s.TELE_TYPE='{1}'";

            string sqlsr = "select nvl(SUM(t.m{0}),0) as count from ess_chart_gw_sr t WHERE t.AREA_NAME='" + Dpt + "' AND t.INCOM_TYPE='GW_INCOME'";
            //出账用户数
            string sqlczyhs = "select nvl(SUM(t.COUNT),0) from ess_chart_gw_yhs t WHERE t.AREA_NAME='" + Dpt + "' AND t.ZHANGQI='{0}' ";

            if (IsDYAdmin)
            {
                sqlsr = sqlsr.Replace("t.AREA_NAME='" + Dpt + "' AND", "");//大领导去除公司限制
                sqlczyhs = sqlczyhs.Replace("t.AREA_NAME='" + Dpt + "' AND", "");//大领导去除公司限制
            }

            int i = 0;//Y数组索引

            #region  表头
            htmltable += "<tr><td>类型\\月份</td>";
            foreach (string m in month)
            {
                htmltable += "<td>" + m + "</td>";
            }
            htmltable += "<td>合计</td></tr>";
            #endregion
            foreach (string stype in types)
            {
                htmltable += "<tr>";
                htmltable += "<td>" + stype + "</td>";
                int y = 0;//数据索引
                double sumrow = 0;//列计算
                object[] _sdata = new object[month.Length];//初始化存放数据的数组
                foreach (string m in month)
                {

                    object count = (stype == "固网收入") ? AdoHelper.ExecuteScalar(string.Format(sqlsr, m)) : AdoHelper.ExecuteScalar(string.Format(sqlczyhs, m));
                    htmltable += "<td>" + count + "</td>";
                    sumrow += Convert.ToDouble(count);

                    _sdata[y] = count;//把数据放入数组
                    nums[i, y] = Convert.ToInt32(count);//放入二维数组，计算列合计
                    //FTchina.Library.LogHelper.Debug(m+stype+_sdata[y]);
                    y += 1;
                }
                _series[i] = new Series { Name = stype, Data = new Data(_sdata) };//组装一条线

                i += 1;
                htmltable += "<td>" + sumrow + "</td>";
                htmltable += "</tr>";
            }
            #region 合计行
            //htmltable += "<tr><td>合计</td>";
            //int sunmall = 0;//合计所有
            //for (int m = 0; m < month.Length; m++)
            //{
            //    int sumcolums = 0;//计算列，从二维数组中计算
            //    for (int n = 0; n < types.Length; n++)
            //    {
            //        // Library.LogHelper.Debug(m.ToString() + n.ToString() + nums[m, n].ToString());
            //        sumcolums += nums[n, m];
            //    }
            //    sunmall += sumcolums;//合计所有的列
            //    htmltable += "<td>" + sumcolums + "</td>";
            //}

            //htmltable += "<td>" + sunmall + "</td></tr>";
            #endregion

            htmltable += "</table>";
            return _series;
        }

        #endregion

        #region 固话收入及用户数变化情况

        /// <summary>
        /// 固话收入及用户数变化情况
        /// </summary>
        /// <param name="month">需要统计的月份string[] { "201201", "201202", "201203" }</param>
        /// <returns></returns>
        public String ChartESSGHIncomeWithUserCount(string Dpt, string[] month, out string htmltable)
        {
            Highcharts chart = new Highcharts("chart")
               .InitChart(new Chart { DefaultSeriesType = ChartTypes.Line })
               .SetTitle(new Title { Text = "固话收入及用户数变化情况" })
               .SetXAxis(new XAxis { Categories = month })
               .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "合计" } })
               .SetTooltip(new Tooltip { Formatter = "function() { return ''+ this.series.name +': '+ this.y; }" })

               .SetPlotOptions(new PlotOptions { Column = new PlotOptionsColumn { Stacking = Stackings.Normal } })

               .SetSeries(GetSeriesGHIncomeWithUserCount(Dpt, month, out htmltable));

            return chart.ToHtmlString(ChartWidth, ChartHeight);
        }
        /// <summary>
        /// 获取纵轴系列
        /// </summary>
        /// <param name="month"></param>
        /// <param name="htmltable"></param>
        /// <returns></returns>
        protected Series[] GetSeriesGHIncomeWithUserCount(string Dpt, string[] month, out string htmltable)
        {
            htmltable = "<table border=1 align=center id=gvList  width='" + ChartWidth + "px' class=tableborder>";
            string[] types = new string[] { "固话收入", "固话用户数" };//统计类型
            int[,] nums = new int[types.Length, month.Length];//用二维数组存放计算出来的数据，便于计算列
            Series[] _series = new Series[types.Length];//初始化Y数组

            // string sql = "SELECT COUNT(s.DEVICE_NUMBER)  FROM  WUWEI75.ww_scbjt_shr_{0} s WHERE s.BIG_DEPT_NAME='" + Dpt + "' AND s.TELE_TYPE='{1}'";

            string sqlsr = "select nvl(SUM(t.m{0}),0) as count from ess_chart_gw_sr t WHERE t.AREA_NAME='" + Dpt + "' AND t.INCOM_TYPE='gddh'";
            //出账用户数
            string sqlczyhs = "select nvl(SUM(t.COUNT),0) from ess_chart_gw_yhs t WHERE t.AREA_NAME='" + Dpt + "' AND t.ZHANGQI='{0}'  AND t.NET_TYPE_CODE ='30'";

            if (IsDYAdmin)
            {
                sqlsr = sqlsr.Replace("t.AREA_NAME='" + Dpt + "' AND", "");//大领导去除公司限制
                sqlczyhs = sqlczyhs.Replace("t.AREA_NAME='" + Dpt + "' AND", "");//大领导去除公司限制
            }
            int i = 0;//Y数组索引

            #region  表头
            htmltable += "<tr><td>类型\\月份</td>";
            foreach (string m in month)
            {
                htmltable += "<td>" + m + "</td>";
            }
            htmltable += "<td>合计</td></tr>";
            #endregion
            foreach (string stype in types)
            {
                htmltable += "<tr>";
                htmltable += "<td>" + stype + "</td>";
                int y = 0;//数据索引
                double sumrow = 0;//列计算
                object[] _sdata = new object[month.Length];//初始化存放数据的数组
                foreach (string m in month)
                {

                    object count = (stype == "固话收入") ? AdoHelper.ExecuteScalar(string.Format(sqlsr, m)) : AdoHelper.ExecuteScalar(string.Format(sqlczyhs, m));
                    htmltable += "<td>" + count + "</td>";
                    sumrow += Convert.ToDouble(count);
                    _sdata[y] = count;//把数据放入数组
                    nums[i, y] = Convert.ToInt32(count);//放入二维数组，计算列合计
                    //FTchina.Library.LogHelper.Debug(m+stype+_sdata[y]);
                    y += 1;
                }
                _series[i] = new Series { Name = stype, Data = new Data(_sdata) };//组装一条线

                i += 1;
                htmltable += "<td>" + sumrow + "</td>";
                htmltable += "</tr>";
            }
            #region 合计行
            //htmltable += "<tr><td>合计</td>";
            //int sunmall = 0;//合计所有
            //for (int m = 0; m < month.Length; m++)
            //{
            //    int sumcolums = 0;//计算列，从二维数组中计算
            //    for (int n = 0; n < types.Length; n++)
            //    {
            //        // Library.LogHelper.Debug(m.ToString() + n.ToString() + nums[m, n].ToString());
            //        sumcolums += nums[n, m];
            //    }
            //    sunmall += sumcolums;//合计所有的列
            //    htmltable += "<td>" + sumcolums + "</td>";
            //}

            //htmltable += "<td>" + sunmall + "</td></tr>";
            #endregion

            htmltable += "</table>";
            return _series;
        }

        #endregion

        #region 宽带收入及用户数变化情况

        /// <summary>
        /// 宽带收入及用户数变化情况
        /// </summary>
        /// <param name="month">需要统计的月份string[] { "201201", "201202", "201203" }</param>
        /// <returns></returns>
        public String ChartESSKDIncomeWithUserCount(string Dpt, string[] month, out string htmltable)
        {
            Highcharts chart = new Highcharts("chart")
               .InitChart(new Chart { DefaultSeriesType = ChartTypes.Line })
               .SetTitle(new Title { Text = "宽带收入及用户数变化情况" })
               .SetXAxis(new XAxis { Categories = month })
               .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "合计" } })
               .SetTooltip(new Tooltip { Formatter = "function() { return ''+ this.series.name +': '+ this.y; }" })

               .SetPlotOptions(new PlotOptions { Column = new PlotOptionsColumn { Stacking = Stackings.Normal } })

               .SetSeries(GetSeriesKDIncomeWithUserCount(Dpt, month, out htmltable));

            return chart.ToHtmlString(ChartWidth, ChartHeight);
        }
        /// <summary>
        /// 获取纵轴系列
        /// </summary>
        /// <param name="month"></param>
        /// <param name="htmltable"></param>
        /// <returns></returns>
        protected Series[] GetSeriesKDIncomeWithUserCount(string Dpt, string[] month, out string htmltable)
        {
            htmltable = "<table border=1 align=center id=gvList  width='" + ChartWidth + "px' class=tableborder>";
            string[] types = new string[] { "宽带收入", "宽带用户数" };//统计类型
            int[,] nums = new int[types.Length, month.Length];//用二维数组存放计算出来的数据，便于计算列
            Series[] _series = new Series[types.Length];//初始化Y数组

            // string sql = "SELECT COUNT(s.DEVICE_NUMBER)  FROM  WUWEI75.ww_scbjt_shr_{0} s WHERE s.BIG_DEPT_NAME='" + Dpt + "' AND s.TELE_TYPE='{1}'";

            string sqlsr = "select nvl(SUM(t.m{0}),0) as count from ess_chart_gw_sr t WHERE t.AREA_NAME='" + Dpt + "' AND t.INCOM_TYPE='hlwyw'";
            //出账用户数
            string sqlczyhs = "select nvl(SUM(t.COUNT),0) from ess_chart_gw_yhs t WHERE t.AREA_NAME='" + Dpt + "' AND t.ZHANGQI='{0}'  AND t.NET_TYPE_CODE ='40'";
            if (IsDYAdmin)
            {
                sqlsr = sqlsr.Replace("t.AREA_NAME='" + Dpt + "' AND", "");//大领导去除公司限制
                sqlczyhs = sqlczyhs.Replace("t.AREA_NAME='" + Dpt + "' AND", "");//大领导去除公司限制
            }
            int i = 0;//Y数组索引

            #region  表头
            htmltable += "<tr><td>类型\\月份</td>";
            foreach (string m in month)
            {
                htmltable += "<td>" + m + "</td>";
            }
            htmltable += "<td>合计</td></tr>";
            #endregion
            foreach (string stype in types)
            {
                htmltable += "<tr>";
                htmltable += "<td>" + stype + "</td>";
                int y = 0;//数据索引
                double sumrow = 0;//列计算
                object[] _sdata = new object[month.Length];//初始化存放数据的数组
                foreach (string m in month)
                {

                    object count = (stype == "宽带收入") ? AdoHelper.ExecuteScalar(string.Format(sqlsr, m)) : AdoHelper.ExecuteScalar(string.Format(sqlczyhs, m));
                    htmltable += "<td>" + count + "</td>";
                    sumrow += Convert.ToDouble(count);
                    _sdata[y] = count;//把数据放入数组
                    nums[i, y] = Convert.ToInt32(count);//放入二维数组，计算列合计
                    //FTchina.Library.LogHelper.Debug(m+stype+_sdata[y]);
                    y += 1;
                }
                _series[i] = new Series { Name = stype, Data = new Data(_sdata) };//组装一条线

                i += 1;
                htmltable += "<td>" + sumrow + "</td>";
                htmltable += "</tr>";
            }
            #region 合计行
            //htmltable += "<tr><td>合计</td>";
            //int sunmall = 0;//合计所有
            //for (int m = 0; m < month.Length; m++)
            //{
            //    int sumcolums = 0;//计算列，从二维数组中计算
            //    for (int n = 0; n < types.Length; n++)
            //    {
            //        // Library.LogHelper.Debug(m.ToString() + n.ToString() + nums[m, n].ToString());
            //        sumcolums += nums[n, m];
            //    }
            //    sunmall += sumcolums;//合计所有的列
            //    htmltable += "<td>" + sumcolums + "</td>";
            //}

            //htmltable += "<td>" + sunmall + "</td></tr>";
            #endregion

            htmltable += "</table>";
            return _series;
        }

        #endregion



        #region 小灵通收入及用户数变化情况

        /// <summary>
        /// 小灵通收入及用户数变化情况
        /// </summary>
        /// <param name="month">需要统计的月份string[] { "201201", "201202", "201203" }</param>
        /// <returns></returns>
        public String ChartESSXLTIncomeWithUserCount(string Dpt, string[] month, out string htmltable)
        {
            Highcharts chart = new Highcharts("chart")
               .InitChart(new Chart { DefaultSeriesType = ChartTypes.Line })
               .SetTitle(new Title { Text = "小灵通收入及用户数变化情况" })
               .SetXAxis(new XAxis { Categories = month })
               .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "合计" } })
               .SetTooltip(new Tooltip { Formatter = "function() { return ''+ this.series.name +': '+ this.y; }" })

               .SetPlotOptions(new PlotOptions { Column = new PlotOptionsColumn { Stacking = Stackings.Normal } })

               .SetSeries(GetSeriesXLTIncomeWithUserCount(Dpt, month, out htmltable));

            return chart.ToHtmlString(ChartWidth, ChartHeight);
        }
        /// <summary>
        /// 获取纵轴系列
        /// </summary>
        /// <param name="month"></param>
        /// <param name="htmltable"></param>
        /// <returns></returns>
        protected Series[] GetSeriesXLTIncomeWithUserCount(string Dpt, string[] month, out string htmltable)
        {
            htmltable = "<table border=1 align=center id=gvList  width='" + ChartWidth + "px' class=tableborder>";
            string[] types = new string[] { "小灵通收入", "小灵通用户数" };//统计类型
            int[,] nums = new int[types.Length, month.Length];//用二维数组存放计算出来的数据，便于计算列
            Series[] _series = new Series[types.Length];//初始化Y数组

            // string sql = "SELECT COUNT(s.DEVICE_NUMBER)  FROM  WUWEI75.ww_scbjt_shr_{0} s WHERE s.BIG_DEPT_NAME='" + Dpt + "' AND s.TELE_TYPE='{1}'";

            string sqlsr = "select nvl(SUM(t.m{0}),0) as count from ess_chart_gw_sr t WHERE t.AREA_NAME='" + Dpt + "' AND t.INCOM_TYPE='wxsh'";
            //出账用户数
            string sqlczyhs = "select nvl(SUM(t.COUNT),0) from ess_chart_gw_yhs t WHERE t.AREA_NAME='" + Dpt + "' AND t.ZHANGQI='{0}'  AND t.NET_TYPE_CODE ='20'";
            if (IsDYAdmin)
            {
                sqlsr = sqlsr.Replace("t.AREA_NAME='" + Dpt + "' AND", "");//大领导去除公司限制
                sqlczyhs = sqlczyhs.Replace("t.AREA_NAME='" + Dpt + "' AND", "");//大领导去除公司限制
            }
            int i = 0;//Y数组索引

            #region  表头
            htmltable += "<tr><td>类型\\月份</td>";
            foreach (string m in month)
            {
                htmltable += "<td>" + m + "</td>";
            }
            htmltable += "<td>合计</td></tr>";
            #endregion
            foreach (string stype in types)
            {
                htmltable += "<tr>";
                htmltable += "<td>" + stype + "</td>";
                int y = 0;//数据索引
                double sumrow = 0;//列计算
                object[] _sdata = new object[month.Length];//初始化存放数据的数组
                foreach (string m in month)
                {

                    object count = (stype == "小灵通收入") ? AdoHelper.ExecuteScalar(string.Format(sqlsr, m)) : AdoHelper.ExecuteScalar(string.Format(sqlczyhs, m));
                    htmltable += "<td>" + count + "</td>";
                    sumrow += Convert.ToDouble(count);
                    _sdata[y] = count;//把数据放入数组
                    nums[i, y] = Convert.ToInt32(count);//放入二维数组，计算列合计
                    //FTchina.Library.LogHelper.Debug(m+stype+_sdata[y]);
                    y += 1;
                }
                _series[i] = new Series { Name = stype, Data = new Data(_sdata) };//组装一条线

                i += 1;
                htmltable += "<td>" + sumrow + "</td>";
                htmltable += "</tr>";
            }
            #region 合计行
            //htmltable += "<tr><td>合计</td>";
            //int sunmall = 0;//合计所有
            //for (int m = 0; m < month.Length; m++)
            //{
            //    int sumcolums = 0;//计算列，从二维数组中计算
            //    for (int n = 0; n < types.Length; n++)
            //    {
            //        // Library.LogHelper.Debug(m.ToString() + n.ToString() + nums[m, n].ToString());
            //        sumcolums += nums[n, m];
            //    }
            //    sunmall += sumcolums;//合计所有的列
            //    htmltable += "<td>" + sumcolums + "</td>";
            //}

            //htmltable += "<td>" + sunmall + "</td></tr>";
            #endregion

            htmltable += "</table>";
            return _series;
        }

        #endregion


        #region 固网收入构成情况

        /// <summary>
        /// 固网收入构成情况
        /// </summary>
        /// <param name="month">需要统计的月份string[] { "201201", "201202", "201203" }</param>
        /// <returns></returns>
        public String ChartESSGWIncome(string Dpt, string[] month, out string htmltable)
        {
            Highcharts chart = new Highcharts("chart")
               .InitChart(new Chart { DefaultSeriesType = ChartTypes.Column })
               .SetTitle(new Title { Text = "固网收入构成情况" })
               .SetXAxis(new XAxis { Categories = month })
               .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "合计" } })
               .SetTooltip(new Tooltip { Formatter = "function() { return ''+ this.series.name +': '+ this.point.y +'<br>总计: '+this.point.stackTotal+'<br>占比 '+ this.percentage.toFixed(2) +'%'; }" })

               .SetPlotOptions(new PlotOptions { Column = new PlotOptionsColumn { Stacking = Stackings.Normal } })

               .SetSeries(GetSeriesGWIncome(Dpt, month, out htmltable));

            return chart.ToHtmlString(ChartWidth, ChartHeight);
        }
        /// <summary>
        /// 获取纵轴系列
        /// </summary>
        /// <param name="month"></param>
        /// <param name="htmltable"></param>
        /// <returns></returns>
        protected Series[] GetSeriesGWIncome(string Dpt, string[] month, out string htmltable)
        {


            htmltable = "<table border=1 align=center id=gvList  width='" + ChartWidth + "px' class=tableborder>";
            string[] types = new string[] { "IT业务", "他网业务", "电话卡", "公用电话", "无线市话", "网元出租", "固定电话", "互联网业务" };//电信类型
            int[,] nums = new int[types.Length, month.Length];//用二维数组存放计算出来的数据，便于计算列
            Series[] _series = new Series[types.Length];//初始化Y数组

            string sqlsr = "select nvl(SUM(t.m{0}),0) as count from ess_chart_gw_sr t WHERE t.AREA_NAME='" + Dpt + "' AND t.INCOM_TYPE='{1}'";
            if (IsDYAdmin)
            {
                sqlsr = sqlsr.Replace("t.AREA_NAME='" + Dpt + "' AND", "");//大领导去除公司限制
            }

            int i = 0;//Y数组索引

            #region  表头
            htmltable += "<tr><td>类型\\月份</td>";
            foreach (string m in month)
            {
                htmltable += "<td>" + m + "</td>";
            }
            htmltable += "<td>合计</td></tr>";
            #endregion
            foreach (string stype in types)
            {
                htmltable += "<tr>";
                htmltable += "<td>" + stype + "</td>";
                int y = 0;//数据索引
                int sumrow = 0;//列计算
                object[] _sdata = new object[month.Length];//初始化存放数据的数组
                foreach (string m in month)
                {
                    object count = AdoHelper.ExecuteScalar(string.Format(sqlsr, m, GetCodeByName(stype)));
                    htmltable += "<td>" + count + "</td>";
                    sumrow += Convert.ToInt32(count);
                    _sdata[y] = count;//把数据放入数组
                    nums[i, y] = Convert.ToInt32(count);//放入二维数组，计算列合计
                    //FTchina.Library.LogHelper.Debug(m+stype+_sdata[y]);
                    y += 1;
                }
                _series[i] = new Series { Name = stype, Data = new Data(_sdata) };//组装一条线
                i += 1;
                htmltable += "<td>" + sumrow + "</td>";
                htmltable += "</tr>";
            }
            #region 合计行
            htmltable += "<tr><td>合计</td>";
            int sunmall = 0;//合计所有
            for (int m = 0; m < month.Length; m++)
            {
                int sumcolums = 0;//计算列，从二维数组中计算
                for (int n = 0; n < types.Length; n++)
                {
                    // Library.LogHelper.Debug(m.ToString() + n.ToString() + nums[m, n].ToString());
                    sumcolums += nums[n, m];
                }
                sunmall += sumcolums;//合计所有的列
                htmltable += "<td>" + sumcolums + "</td>";
            }

            htmltable += "<td>" + sunmall + "</td></tr>";
            #endregion

            htmltable += "</table>";
            return _series;
        }


        /// <summary>
        /// 通过名称获取代码
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        protected string GetCodeByName(string name)
        {
            string[] typesName = new string[] { "IT业务", "他网业务", "电话卡", "公用电话", "无线市话", "网元出租", "固定电话", "互联网业务" };//电信类型
            string[] typesCode = new string[] { "ityw", "twyw", "dhk", "gydhk", "wxsh", "wycz", "gddh", "hlwyw" };//电信CODE

            int index = typesName.ToList().IndexOf(name);
            return typesCode[index];

        }
        #endregion



        #endregion


        #region 全业务运营
        #region 全业务收入构成情况

        /// <summary>
        /// 全业务收入构成情况
        /// </summary>
        /// <param name="month">需要统计的月份string[] { "201201", "201202", "201203" }</param>
        /// <returns></returns>
        public String ChartESSQYWIncome(string Dpt, string[] month, out string htmltable)
        {
            Highcharts chart = new Highcharts("chart")
               .InitChart(new Chart { DefaultSeriesType = ChartTypes.Column })
               .SetTitle(new Title { Text = "全业务收入构成情况" })
               .SetXAxis(new XAxis { Categories = month })
               .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "合计" } })
               .SetTooltip(new Tooltip { Formatter = "function() { return ''+ this.series.name +': '+ this.point.y +'<br>总计: '+this.point.stackTotal+'<br>占比 '+ this.percentage.toFixed(2) +'%'; }" })

               .SetPlotOptions(new PlotOptions { Column = new PlotOptionsColumn { Stacking = Stackings.Normal } })

               .SetSeries(GetSeriesQYWIncome(Dpt, month, out htmltable));

            return chart.ToHtmlString(ChartWidth, ChartHeight);
        }
        /// <summary>
        /// 获取纵轴系列
        /// </summary>
        /// <param name="month"></param>
        /// <param name="htmltable"></param>
        /// <returns></returns>
        protected Series[] GetSeriesQYWIncome(string Dpt, string[] month, out string htmltable)
        {


            htmltable = "<table border=1 align=center id=gvList  width='" + ChartWidth + "px' class=tableborder>";
            string[] types = new string[] { "WCDMA", "OCS3G", "GSM", "OCS2G", "IT业务", "他网业务", "电话卡", "公用电话", "无线市话", "网元出租", "固定电话", "互联网业务" };//电信类型
            int[,] nums = new int[types.Length, month.Length];//用二维数组存放计算出来的数据，便于计算列
            Series[] _series = new Series[types.Length];//初始化Y数组

            string sqlywsr = "select nvl(SUM(jingyingshou),0) from ess_chart_yw_ywsrjyhs t WHERE t.BIG_DEPT_NAME='" + Dpt + "' AND t.ZHANGQI='{0}' AND t.TELE_TYPE='{1}' ";

            string sqlgwsr = "select nvl(SUM(t.m{0}),0)  from ess_chart_gw_sr t WHERE t.AREA_NAME='" + Dpt + "' AND t.INCOM_TYPE='{1}'";
            if (IsDYAdmin)
            {
                sqlywsr = sqlywsr.Replace("t.BIG_DEPT_NAME='" + Dpt + "' AND", "");//大领导去除公司限制
                sqlgwsr = sqlgwsr.Replace("t.AREA_NAME='" + Dpt + "' AND", "");//大领导去除公司限制
            }

            int i = 0;//Y数组索引

            #region  表头
            htmltable += "<tr><td>类型\\月份</td>";
            foreach (string m in month)
            {
                htmltable += "<td>" + m + "</td>";
            }
            htmltable += "<td>合计</td></tr>";
            #endregion
            foreach (string stype in types)
            {
                htmltable += "<tr>";
                htmltable += "<td>" + stype + "</td>";
                int y = 0;//数据索引
                int sumrow = 0;//列计算
                object[] _sdata = new object[month.Length];//初始化存放数据的数组
                foreach (string m in month)
                {
                    object count;
                    switch (stype)
                    {
                        case "WCDMA":
                        case "OCS3G":
                        case "GSM":
                        case "OCS2G":
                            {
                                count = AdoHelper.ExecuteScalar(string.Format(sqlywsr, m, GetCodeByNameQYW(stype)));
                                break;
                            }
                        default:
                            {
                                count = AdoHelper.ExecuteScalar(string.Format(sqlgwsr, m, GetCodeByNameQYW(stype)));
                                break;
                            }
                    }

                    htmltable += "<td>" + count + "</td>";
                    sumrow += Convert.ToInt32(count);
                    _sdata[y] = count;//把数据放入数组
                    nums[i, y] = Convert.ToInt32(count);//放入二维数组，计算列合计
                    //FTchina.Library.LogHelper.Debug(m+stype+_sdata[y]);
                    y += 1;
                }
                _series[i] = new Series { Name = stype, Data = new Data(_sdata) };//组装一条线
                i += 1;
                htmltable += "<td>" + sumrow + "</td>";
                htmltable += "</tr>";
            }
            #region 合计行
            htmltable += "<tr><td>合计</td>";
            int sunmall = 0;//合计所有
            for (int m = 0; m < month.Length; m++)
            {
                int sumcolums = 0;//计算列，从二维数组中计算
                for (int n = 0; n < types.Length; n++)
                {
                    // Library.LogHelper.Debug(m.ToString() + n.ToString() + nums[m, n].ToString());
                    sumcolums += nums[n, m];
                }
                sunmall += sumcolums;//合计所有的列
                htmltable += "<td>" + sumcolums + "</td>";
            }

            htmltable += "<td>" + sunmall + "</td></tr>";
            #endregion

            htmltable += "</table>";
            return _series;
        }


        /// <summary>
        /// 通过名称获取代码
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        protected string GetCodeByNameQYW(string name)
        {
            string[] typesName = new string[] { "WCDMA", "OCS3G", "GSM", "OCS2G", "IT业务", "他网业务", "电话卡", "公用电话", "无线市话", "网元出租", "固定电话", "互联网业务" };//电信类型
            string[] typesCode = new string[] { "WCDMA", "OCS3G", "GSM", "OCS2G", "ityw", "twyw", "dhk", "gydhk", "wxsh", "wycz", "gddh", "hlwyw" };//电信CODE

            int index = typesName.ToList().IndexOf(name);
            return typesCode[index];

        }
        #endregion
        #region 全业务用户数分布情况

        /// <summary>
        /// 全业务用户数分布情况
        /// </summary>
        /// <param name="month">需要统计的月份string[] { "201201", "201202", "201203" }</param>
        /// <returns></returns>
        public String ChartESSQYWUserCount(string Dpt, string[] month, out string htmltable)
        {
            Highcharts chart = new Highcharts("chart")
               .InitChart(new Chart { DefaultSeriesType = ChartTypes.Column })
               .SetTitle(new Title { Text = "全业务用户数分布情况" })
               .SetXAxis(new XAxis { Categories = month })
               .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "合计" } })
               .SetTooltip(new Tooltip { Formatter = "function() { return ''+ this.series.name +': '+ this.point.y +'<br>总计: '+this.point.stackTotal+'<br>占比 '+ this.percentage.toFixed(2) +'%'; }" })

               .SetPlotOptions(new PlotOptions { Column = new PlotOptionsColumn { Stacking = Stackings.Normal } })

               .SetSeries(GetSeriesQYWUserCount(Dpt, month, out htmltable));

            return chart.ToHtmlString(ChartWidth, ChartHeight);
        }
        /// <summary>
        /// 获取纵轴系列
        /// </summary>
        /// <param name="month"></param>
        /// <param name="htmltable"></param>
        /// <returns></returns>
        protected Series[] GetSeriesQYWUserCount(string Dpt, string[] month, out string htmltable)
        {


            htmltable = "<table border=1 align=center id=gvList  width='" + ChartWidth + "px' class=tableborder>";
            string[] types = new string[] { "WCDMA", "OCS3G", "GSM", "OCS2G", "无线市话", "普通电话", "ISDN", "中继线", "公用电话", "预付费无线市话", "互联网接入业务", "基础数据", "设备出租", "智能网增值业务" };//电信类型
            int[,] nums = new int[types.Length, month.Length];//用二维数组存放计算出来的数据，便于计算列
            Series[] _series = new Series[types.Length];//初始化Y数组

            //移网用户数
            string sqlywyhs = "select nvl(sum(t.CHUZHANGYONGHUSHU),0) from ess_chart_yw_ywsrjyhs t WHERE t.BIG_DEPT_NAME='" + Dpt + "' AND t.ZHANGQI='{0}' AND t.TELE_TYPE='{1}' ";

            //固网用户数
            string sqlgwyhs = "select nvl(SUM(t.COUNT),0) from ess_chart_gw_yhs t WHERE t.AREA_NAME='" + Dpt + "' AND t.ZHANGQI='{0}'  AND t.NET_TYPE_CODE ='{1}'";

            if (IsDYAdmin)
            {
                sqlywyhs = sqlywyhs.Replace("t.BIG_DEPT_NAME='" + Dpt + "' AND", "");//大领导去除公司限制
                sqlgwyhs = sqlgwyhs.Replace("t.AREA_NAME='" + Dpt + "' AND", "");//大领导去除公司限制
            }
            
            int i = 0;//Y数组索引

            #region  表头
            htmltable += "<tr><td>类型\\月份</td>";
            foreach (string m in month)
            {
                htmltable += "<td>" + m + "</td>";
            }
            htmltable += "<td>合计</td></tr>";
            #endregion
            foreach (string stype in types)
            {
                htmltable += "<tr>";
                htmltable += "<td>" + stype + "</td>";
                int y = 0;//数据索引
                int sumrow = 0;//列计算
                object[] _sdata = new object[month.Length];//初始化存放数据的数组
                foreach (string m in month)
                {
                    object count;
                    switch (stype)
                    {
                        case "WCDMA":
                        case "OCS3G":
                        case "GSM":
                        case "OCS2G":
                            {
                                count = AdoHelper.ExecuteScalar(string.Format(sqlywyhs, m, GetCodeByNameQYWUserCount(stype)));
                                break;
                            }
                        default:
                            {
                                count = AdoHelper.ExecuteScalar(string.Format(sqlgwyhs, m, GetCodeByNameQYWUserCount(stype)));
                                break;
                            }
                    }

                    htmltable += "<td>" + count + "</td>";
                    sumrow += Convert.ToInt32(count);
                    _sdata[y] = count;//把数据放入数组
                    nums[i, y] = Convert.ToInt32(count);//放入二维数组，计算列合计
                    //FTchina.Library.LogHelper.Debug(m+stype+_sdata[y]);
                    y += 1;
                }
                _series[i] = new Series { Name = stype, Data = new Data(_sdata) };//组装一条线
                i += 1;
                htmltable += "<td>" + sumrow + "</td>";
                htmltable += "</tr>";
            }
            #region 合计行
            htmltable += "<tr><td>合计</td>";
            int sunmall = 0;//合计所有
            for (int m = 0; m < month.Length; m++)
            {
                int sumcolums = 0;//计算列，从二维数组中计算
                for (int n = 0; n < types.Length; n++)
                {
                    // Library.LogHelper.Debug(m.ToString() + n.ToString() + nums[m, n].ToString());
                    sumcolums += nums[n, m];
                }
                sunmall += sumcolums;//合计所有的列
                htmltable += "<td>" + sumcolums + "</td>";
            }

            htmltable += "<td>" + sunmall + "</td></tr>";
            #endregion

            htmltable += "</table>";
            return _series;
        }

        /// <summary>
        /// 通过名称获取代码
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        protected string GetCodeByNameQYWUserCount(string name)
        {
            string[] typesName = new string[] { "WCDMA", "OCS3G", "GSM", "OCS2G", "无线市话", "普通电话", "ISDN", "中继线", "公用电话", "预付费无线市话", "互联网接入业务", "基础数据", "设备出租", "智能网增值业务" };//电信类型
            string[] typesCode = new string[] { "WCDMA", "OCS3G", "GSM", "OCS2G", "20", "30", "31", "32", "34", "35", "40", "45", "51", "61" };//电信CODE

            int index = typesName.ToList().IndexOf(name);
            return typesCode[index];

        }
        #endregion
        #endregion

    }
}